package ui.login_ui;

import java.awt.GraphicsEnvironment;
import java.awt.Rectangle;

import javaRMI.RMIClient;

import javax.swing.JFrame;
import javax.swing.JPanel;

import logic.utility_logic.NetConnectException;

@SuppressWarnings("serial")
public class LoginFrame extends JFrame {
	private int width;
	private int height;
	private String background = "resource\\loginpic\\loginbg.jpg";
	private static final double GOLDEN_RATIO = (Math.sqrt(5) - 1)/2;
	private LoginBackgroundPanel lbp;
 	public LoginFrame(RMIClient rmi){
		GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
		Rectangle rt = ge.getMaximumWindowBounds();
		int w = rt.width;
		int h = rt.height;
		width = w * 2/3;
		height =(int)( width * GOLDEN_RATIO);
		this.setBounds((w - width)/2, (h - height)/2, width, height);
		this.setResizable(false);
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);	
		lbp = new LoginBackgroundPanel(this,background,rmi);
		((JPanel)getContentPane()).setOpaque(false);
		lbp.setBounds(0, 0, width, height);
 		this.getLayeredPane().add(lbp,Integer.MIN_VALUE);
 		this.repaint();
	}
	public static void main(String[] args){
		RMIClient rmi = null;
		try {
			rmi = new RMIClient();
		} catch (NetConnectException e) {
			e.printStackTrace();
		}
		LoginFrame lf = new LoginFrame(rmi);
		lf.setVisible(true);
	}
}
